package zlatan_demo02_constructor

object ClassDemo01 {
  //主构造器   class后参数赋值，类型不可省略
  class Person(val name: String = "张三", val age: Int = 23) {
    println("调用主构造器！！")

  }

  def main(args: Array[String]): Unit = {
    val p1 = new Person()    //空参
    println(s"p1:${p1.name},${p1.age}")     //张三，23

    val p2 = new Person("李四", age = 24)    //全参
    println(s"p2:${p2.name},${p2.age}")    //李四，24

    val p3 = new Person(age = 30)
    println(s"p3:${p3.name},${p3.age}")   //张三，30
  }
}
